import os

from PIL import Image

# 切割图片
def cut_images():
    y = 0
    for i in range(1, 690):
        img = Image.open('./images/%s.png' % str(i))
        s_img = img.crop((0,0,76,76))
        s_img.save("./cut_images/s_%s.png" % str(y))
        y += 1
        s_img = img.crop((76, 0, 152, 76))
        s_img.save("./cut_images/s_%s.png" % str(y))
        y += 1
        s_img = img.crop((152, 0, 228, 76))
        s_img.save("./cut_images/s_%s.png" % str(y))
        y +=1
        s_img = img.crop((228, 0, 304, 76))
        s_img.save("./cut_images/s_%s.png" % str(y))
        y += 1
        print(y)

# 重命名
def rename():
    y = 0
    for i in range(2800):
        a = './cut_images/%s.png' % str(i)
        if os.path.isfile(a):
            y += 1
            b = './cut_images/%s.png' % str(y)
            if not os.path.isfile(b):
                os.rename(a, b)



def main():
    #cut_images()
    rename()


if __name__ == '__main__':
    main()